import request from "@/utils/request.js";

const Api = {
    create: "/v1/system/menu",
    createButton: "/v1/system/menuButton",
    delete: "/v1/system/menu/",
    deleteButton: "/v1/system/menuButton/",
    updateButton: "/v1/system/menuButton/",
    menuRouteList: "/v1/system/menu/route/list",
    menuRouteTree: "/v1/system/menu/route/tree",
    menuButtonTree: "/v1/system/menu/button/tree",
    getObj: "/v1/system/menu/",
}

/**
 * 创建菜单
 */
export const create_menu = (data) => {
    return request({
        url: Api.create,
        method: "POST",
        data,
    });
}

/**
 * 创建菜单权限按钮
 */
export const create_menu_button = (data) => {
    return request({
        url: Api.createButton,
        method: "POST",
        data,
    });
}

/**
 * 删除菜单
 */
export const delete_menu = (id) => {
    return request({
        url: Api.delete + id,
        method: "DELETE",
    });
};

/**
 * 删除菜单权限按钮
 */
export const delete_menu_button = (id) => {
    return request({
        url: Api.deleteButton + id,
        method: "DELETE",
    });
};

/**
 * 更新菜单权限对象
 */
export const update_menu_button = (id, data) => {
    return request({
        url: Api.updateButton + id,
        method: "PUT",
        data,
    });
};

/**
 * 获取菜单树列表
 */
export const get_menu_route_list = (params) => {
    return request({
        url: Api.menuRouteList,
        method: "GET",
        params,
    });
};

/**
 * 获取用户角色菜单树
 */
export const getMenuRouteTree = (params) => {
    return request({
        url: Api.menuRouteTree,
        method: "GET",
        params,
    });
};

/**
 * 获取菜单权限树列表
 */
export const get_menu_button_tree = (params) => {
    return request({
        url: Api.menuButtonTree,
        method: "GET",
        params,
    });
};

/**
 * 获取菜单权限对象
 */
export const get_menu_obj = (id) => {
    return request({
        url: Api.getObj + id,
        method: "GET",
    });
};